class Person {
  name: string;
  age: number;
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }

  speak() {
    console.log(`我叫:${this.name},今年${this.age}岁`);
  }
}

const p1 = new Person("张三", 18);
console.log(p1);
p1.speak();

//一个学生继承这个人
class Student extends Person {
  grade: string;
  constructor(name: string, age: number, grade: string) {
    super(name, age);
    this.grade = grade;
  }
  study() {
    console.log(`${this.name}正在努力学习中......`);
  }
  //重写父类的方法: override:真正覆盖父类的(这个名称写错了会提示)
  override speak() {
    console.log(`我叫:${this.name},今年${this.age}岁`);
  }
}

const s1 = new Student("李艺彤", 16, "高三");
s1.study();
